package android.bluebox.model;


public class Workspace {
	
	private int id = 0;
	private String name = "";
	private String hostIP = "";
	private LocationResult location;
	private String lastVisited = "";
	
	public void setHostIP(String hostIP) {
		this.hostIP = hostIP;
	}
	
	public String getHostIP() {
		return hostIP;
	}
	
	public void setLocation(LocationResult _location) {
		location = _location;
	}
	
	public void setLocation(float _latitude, float _longitude) {
		location = new LocationResult(_latitude, _longitude);
	}
	
	public LocationResult getLocation() {
		return location;
	}
	
	public String getStringLocation() {
		if (location != null)
			return "Latitude: " + location.getLatitude() + "\nLongitude: " + location.getLongitude();
		else
			return "";
	}
	
	public float getLatitude() {
		if (location == null)
			return -1000;
		return location.getLatitude();
	}
	
	public float getLongitude() {
		if (location == null)
			return -1000;
		return location.getLongitude();
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public void setLastVisited(String lastVisited) {
		this.lastVisited = lastVisited;
	}
	
	public String getLastVisited() {
		return lastVisited;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public int getId() {
		return id;
	}
	
	public void resetLastVisited() {
		setLastVisited(StaticBox.getCurrentDate());
	}
	
	public boolean isAvailable() {
		if (hostIP.equals("") || hostIP == null)
			return false;
		else
			return StaticBox.netBox.checkIP(hostIP);
	}
	
	public float getDistance() {
		return Math.round(StaticBox.distance(location) * 1000);
	}
}